package com.qiyeji.real_estate.service;

import com.qiyeji.real_estate.entity.IO;
import org.springframework.stereotype.Service;

import java.io.File;

@Service
public class IOService {
    //创建初始文件夹
    public void mkdirFile(String fileName){
        IO io=new IO(fileName);
    }
    //获取该文件下的所有子文件
    public String[] getSubfile(String fileName){//fileName绝对路径
        File file=new File(fileName);
        return file.list();
    }
    //获取该文件的父文件路径
    public String getParentfile(String fileName){
        File file=new File(fileName);
//        return file.getParent();
        if(file.getParentFile().getName().equals("FileSystem")){
            return "";
        }
        return "\\"+file.getParentFile().getName();
    }
    //判断是否是文件
    public boolean isFile(String fileName){
        File file=new File(fileName);
        return file.isFile();
    }
    //判断是否是文件夹
    public boolean isFolder(String fileName){
        File file=new File(fileName);
        return file.isDirectory();
    }
}
